package com.cxg.fairy.app;

import com.cxg.fairy.util.storage.LattePreference;

/**
 * Created by CFairy on 2017/11/22
 */

public class AccountManager {

    private enum SignTag {
        SIGN_TAG,
        UUID,
        TEL
    }

    //保存用户登录状态，登录后调用
    public static void setSignState(boolean state) {
        LattePreference.setAppFlag(SignTag.SIGN_TAG.name(), state);
    }

    public static void setSignUUID(String UUID) {
        LattePreference.addCustomAppProfile(SignTag.UUID.name(), UUID);
    }

    public static String getSignUUID() {
        return LattePreference.getCustomAppProfile(SignTag.UUID.name());
    }

    public static void setSignTEL(String TEL) {
        LattePreference.addCustomAppProfile(SignTag.TEL.name(), TEL);
    }

    public static String getSignTEL() {
        return LattePreference.getCustomAppProfile(SignTag.TEL.name());
    }

    private static boolean isSignIn() {
        return LattePreference.getAppFlag(SignTag.SIGN_TAG.name());
    }

    public static void checkAccount(IUserChecker checker) {
        if (isSignIn()) {
            checker.onSignIn();
        } else {
            checker.onNotSignIn();
        }
    }
}
